$gtf_file=$ARGV[0];
my $up_stream=$ARGV[1];
my $down_stream=$ARGV[2];
my @chrs=(1..22);
open(FH,"<$gtf_file") or die;
my @in=<FH>;
chomp(@in);
close(FH);
my @out;
my $bed_file=$gtf_file.".excludeChrX.minusUpstream$up_stream.plusDownstream$down_stream.bed";
open(OUT,">$bed_file");
foreach my $chr(@chrs){
	$chr = "chr".$chr;
	print("$chr\n");
	foreach my $line(@in){
		my @splitin = split "\t",$line;
		#next if($splitin[0] ne "chr11" || $splitin[3]<7000000 || $splitin[4]>9000000);
		next if($splitin[0]=~/\_/ or $splitin[0]!~/^$chr$/);
		my $start = $splitin[3];
		my $end = $splitin[4];
		if($splitin[6] eq '+'){
			$start -= $up_stream;
                	$end += $down_stream;
		}
		else{
			$start -= $down_stream;
                        $end += $up_stream;
		}
	#	print OUT "$splitin[0]\t$start\t$end\texon\t$splitin[5]\t$splitin[6]\n";
		print OUT "$splitin[0]\t$start\t$end\n";
#	push(@out,"$splitin[0]\t$splitin[3]\t$splitin[4]\texon\t$splitin[5]\t$splitin[6]\n");
	}
	
} 



close(OUT);
